|
Polymorphism is a means to uniformly handle objects of classes related by inheritance. It allows to send a message to an object without having to know at compile time about the exact class of the receiver. Hence, binding of a message to an implementation of a message has to take place at run time (dynamic binding). To demonstrate polymorphism, we will give an example: This can be implemented very elegant by application of polymorphism. The communication controller can define a polymorphic object which represents the received data packet:
The transfomation can be done uniformly (without taking care about the different data representations of the received packets) by the invocation of the polymorphic method unify:
loc_packet is an instantiation of class unified_packet |
|